package com.lazycat.backend.controller.address;

import com.alibaba.fastjson.JSONObject;
import com.lazycat.backend.service.address.AddAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class AddAddressController {
    @Autowired
    private AddAddressService addAddressService;

    @PostMapping("/address/add/")
    public Map<String, Object> add(@RequestBody JSONObject map) {
        Integer userId = map.getInteger("user_id");
        JSONObject address = map.getJSONObject("address");
        String tag = address.getString("tag");
        String address_ = address.getString("address");
        String contact = address.getString("contact");
        String phoneNumber = address.getString("phone_number");
        return addAddressService.add(userId, tag, address_, contact, phoneNumber);



    }

}
